home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
19
/
madtrb11.zip
/
LISTSUBS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-07-13
|
5KB
|
158 lines
PROGRAM ListSubs;
{
This program prints a listing of all procedure and function
delcarations in a Pascal source program.
Source: "LISTSUBS: A Procedure/Function Lister", TUG Lines Volume I Issue 5
Author: Fritz Ziegler
Date: 7/15/84
Application: All systems
}
type
fil_type = text;
filname_type = string[14]; { x:yyyyyyyy.zzz }
fil_lin_type = string[255];
maxstring = string[255];
identifier_type = string[127];
var
fil : fil_type;
filname : filname_type;
procedure close_files(var fil : fil_type);
begin { close_files }
close(fil);
end; { close_files }
procedure get_filname(var filname : filname_type);
begin { get_filname }
filname := '';
writeln;
write('List procedures and functions on what file (Q to quit) ? ');
readln(filname);
writeln;
end; { get_filname }
procedure open_files(filname : filname_type; var fil : fil_type);
begin { open_files }
assign(fil, filname);
reset(fil);
end; { open_files }
procedure print_procfunc_list(var fil : fil_type;
filname: filname_type);
var
fil_lin : fil_lin_type;
first_word : identifier_type;
is_cont_lin : boolean;
function is_procfunc(var fil_lin: fil_lin_type;
var is_cont_lin : boolean): boolean;
procedure get_first_word(fil_lin : fil_lin_type;
var first_word: identifier_type);
label return;
var
i, i2 : integer;
begin { get_first_word }
first_word := '';
for i := 1 to length(fil_lin) do
begin
if fil_lin[i] <> ' ' then
begin
for i2 := i to length(fil_lin) do
begin
if fil_lin[i2] <> ' ' then
first_word := concat(first_word, upcase(fil_lin[i2]))
else
begin
goto return;
end; { else }
end; { for }
end; { if }
end; { for }
return:
end; { get_first_word }
procedure set_cont_flag(fil_lin : fil_lin_type;
first_word: identifier_type;
var is_cont_lin: boolean);
begin {set_cont_flag}
if (first_word = 'PROCEDURE') or
(first_word = 'FUNCTION') or
(first_word = 'PROGRAM') then
if (pos('(', fil_lin) <> 0) and (pos(')', fil_lin) = 0) then
is_cont_lin := true;
end; {set_cont_flag}
begin { is_procfunc }
get_first_word(fil_lin, first_word);
if not is_cont_lin then set_cont_flag(fil_lin,
first_word, is_cont_lin);
if (first_word = 'PROCEDURE') or
(first_word = 'FUNCTION') or
(first_word = 'PROGRAM') or
(first_word = 'END.') or
(is_cont_lin) then
is_procfunc := true
else
is_procfunc := false;
end; { is_procfunc }
procedure clrsav_cont_flag(fil_lin : fil_lin_type;
var is_cont_lin: boolean);
begin {clrsav_cont_flag}
if (pos(')', fil_lin) <> 0) then
is_cont_lin := false;
end; {clrsav_cont_flag}
begin { print_procfunc_list }
writeln(' *** LISTSUBS ***');
writeln(' ');
writeln(' A list of subprograms for the file ', filname);
writeln(' ');
writeln(' ');
writeln(lst, ' *** LISTSUBS ***');
writeln(lst, ' ');
writeln(lst, ' A list of subprograms for the file ',
filname);
writeln(lst, ' ');
writeln(lst, ' ');
is_cont_lin := false;
while not eof(fil) do
begin
fil_lin := '';
readln(fil, fil_lin);
if is_procfunc(fil_lin, is_cont_lin) then
begin
writeln(fil_lin);
writeln(' ');
writeln(lst, fil_lin);
writeln(lst, ' ');
end; { if }
if is_cont_lin then clrsav_cont_flag(fil_lin, is_cont_lin);
end; { while }
end; { print_procfunc_list }
procedure upc_filname(var filname : filname_type);
var
i : integer;
begin { upc_filname }
for i := 1 to length(filname) do filname[i] := upcase(filname[i]);
end; { upc_filname }
begin { main program }
get_filname(filname);
upc_filname(filname);
while filname <> 'Q' do
begin
open_files(filname, fil);
print_procfunc_list(fil, filname);
close_files(fil);
get_filname(filname);
upc_filname(filname);
end; { while }
end. { listsubs }